package stack;

import java.util.Stack;

public class StackQueue {
    Stack<Integer> stack1;
    Stack<Integer> stack2;

    public StackQueue() {
        stack1 = new Stack<>();
        stack2 = new Stack<>();
    }

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        while (!stack1.empty()) {
            stack2.push(stack1.pop());
        }
        int n = stack2.pop();
        while (!stack2.empty()) {
            stack1.push(stack2.pop());
        }
        return n;
    }

    public int peek() {
        while (!stack1.empty()) {
            stack2.push(stack1.pop());
        }
        int n = stack2.peek();
        while (!stack2.empty()) {
            stack1.push(stack2.pop());
        }
        return n;
    }

    public boolean empty() {
        if (stack1.empty()) {
            return true;
        }
        return false;
    }
}
